package com.rr.easy;

import java.util.Stack;

/**
 * @author zhuangcanrun
 * @Date 2022/01/07/13:04
 * @description
 **/

/*
* https://leetcode-cn.com/problems/maximum-nesting-depth-of-the-parentheses/
* */
public class MaxDepth {
    public int maxDepth(String s) {
        int ans = 0;
        int tempAns = 0;
        int length = s.length();
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            if (c == '(') {
                tempAns++;
                ans = Math.max(ans, tempAns);
            } else if (c == ')') {
                tempAns--;
            }
        }
        return ans;
    }
}
